package com.songtai.action.front;

import java.util.List;

import com.songtai.action.SongtaiActionSupport;
import com.songtai.po.PhotoObj;
import com.songtai.po.PublicObj;
import com.songtai.pojo.NodeView;
import com.songtai.service.ImageService;
import com.songtai.service.NodeService;
import com.songtai.service.PublicObjService;
import com.songtai.util.Pager;

public class ExampleAction extends SongtaiActionSupport {

	private static final long serialVersionUID = 6298110583371810326L;
	private Long nodeid;
	private Pager<PhotoObj> egs;
	private List<NodeView> nodeItems;
	private String keyword;
	private int currentPage;
	private ImageService imageService;
	private NodeService nodeService;
	private List<PhotoObj> sliderList;
	private Long slider_id = 2L;
	private int type = 0;
	private List<PhotoObj> geg;
	private String pid;
	private List<PublicObj> qq;
	private PublicObjService publicObjService;

	public String examples() throws Exception {
		currentPage = currentPage < 1 ? 1 : currentPage;
		nodeid = nodeid == null ? 15L : nodeid;
		nodeItems = nodeService.getAllBrothers(nodeid);
		int pageSize = 8;
		//egs = imageService.getAllImage(currentPage, pageSize, PhotoObj.TYPE_CASE, nodeid);
		egs = imageService.getAllImagesGroupByBiaoqian(currentPage, pageSize,  PhotoObj.TYPE_CASE, nodeid);
		egs.setPageSize(pageSize);

		sliderList = imageService.getImageByNodeid(slider_id, 10, PhotoObj.TYPE_SLIDER);

		qq = publicObjService.getObjsByNid("23");
		return SUCCESS;
	}

	public String searchCases() throws Exception {
		if (keyword == null || "".equals(keyword)) {
			return null;
		}
		type = 1;
		nodeid = nodeid == null ? 15L : nodeid;
		currentPage = currentPage < 1 ? 1 : currentPage;
		nodeItems = nodeService.getAllBrothers(nodeid);
		int pageSize = 8;
		egs = imageService.getAllImage(keyword, currentPage, pageSize, PhotoObj.TYPE_CASE);
		egs.setPageSize(pageSize);

		sliderList = imageService.getImageByNodeid(slider_id, 10, PhotoObj.TYPE_SLIDER);

		qq = publicObjService.getObjsByNid("23");
		return SUCCESS;
	}

	public String caseDetail() throws Exception {
		nodeid = nodeid == null ? 15L : nodeid;
		nodeItems = nodeService.getAllBrothers(nodeid);
		sliderList = imageService.getImageByNodeid(slider_id, 10, PhotoObj.TYPE_SLIDER);
		geg= imageService.getGroupImages(pid);
		qq = publicObjService.getObjsByNid("23");
		return SUCCESS;
	}

	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}

	/**
	 * @return the sliderList
	 */
	public List<PhotoObj> getSliderList() {
		return sliderList;
	}

	/**
	 * @param sliderList
	 *            the sliderList to set
	 */
	public void setSliderList(List<PhotoObj> sliderList) {
		this.sliderList = sliderList;
	}

	/**
	 * @return the currentPage
	 */
	public int getCurrentPage() {
		return currentPage;
	}

	/**
	 * @return the imageService
	 */
	public ImageService getImageService() {
		return imageService;
	}

	/**
	 * @param imageService
	 *            the imageService to set
	 */
	public void setImageService(ImageService imageService) {
		this.imageService = imageService;
	}

	/**
	 * @param currentPage
	 *            the currentPage to set
	 */
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	/**
	 * @return the nodeid
	 */
	public Long getNodeid() {
		return nodeid;
	}

	/**
	 * @param nodeid
	 *            the nodeid to set
	 */
	public void setNodeid(Long nodeid) {
		this.nodeid = nodeid;
	}

	/**
	 * @return the egs
	 */
	public Pager<PhotoObj> getEgs() {
		return egs;
	}

	/**
	 * @param egs
	 *            the egs to set
	 */
	public void setEgs(Pager<PhotoObj> egs) {
		this.egs = egs;
	}

	/**
	 * @return the nodeItems
	 */
	public List<NodeView> getNodeItems() {
		return nodeItems;
	}

	/**
	 * @param nodeItems
	 *            the nodeItems to set
	 */
	public void setNodeItems(List<NodeView> nodeItems) {
		this.nodeItems = nodeItems;
	}

	/**
	 * @return the keyword
	 */
	public String getKeyword() {
		return keyword;
	}

	/**
	 * @param keyword
	 *            the keyword to set
	 */
	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	/**
	 * @return the nodeService
	 */
	public NodeService getNodeService() {
		return nodeService;
	}

	/**
	 * @param nodeService
	 *            the nodeService to set
	 */
	public void setNodeService(NodeService nodeService) {
		this.nodeService = nodeService;
	}


	/**
	 * @return the geg
	 */
	public List<PhotoObj> getGeg() {
		return geg;
	}

	/**
	 * @param geg the geg to set
	 */
	public void setGeg(List<PhotoObj> geg) {
		this.geg = geg;
	}

	/**
	 * @return the pid
	 */
	public String getPid() {
		return pid;
	}

	/**
	 * @param pid
	 *            the pid to set
	 */
	public void setPid(String pid) {
		this.pid = pid;
	}

	public List<PublicObj> getQq() {
		return qq;
	}

	public void setQq(List<PublicObj> qq) {
		this.qq = qq;
	}

	/**
	 * @return the publicObjService
	 */
	public PublicObjService getPublicObjService() {
		return publicObjService;
	}

	/**
	 * @param publicObjService
	 *            the publicObjService to set
	 */
	public void setPublicObjService(PublicObjService publicObjService) {
		this.publicObjService = publicObjService;
	}

}
